﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAO
{
    public static class HoaDon_DiemTichLuyDAO
    {

        public static QL_HuongRungEntities db = new QL_HuongRungEntities();
        public static int layDiemTichLuy(decimal tongTienHD)
        {
            if (tongTienHD < db.HOADON_DIEMTICHLUY.First().GiaTriDau)
                return 0;

            var gtc = db.HOADON_DIEMTICHLUY.Where(p => p.GiaTriCuoi >= tongTienHD).Min(p => p.GiaTriCuoi);          

            int kq = db.HOADON_DIEMTICHLUY.Where(p => p.GiaTriCuoi == gtc).Single().DiemQuyDoi;

            return kq;
        }
    }
}
